home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / autoconf.lha / autoconf-1.4 / autoconf.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1993-05-15  |  3KB  |  113 lines

  1. #!/bin/sh
  2. # autoconf -- create `configure' using m4 macros
  3. # Copyright (C) 1992, 1993 Free Software Foundation, Inc.
  4.  
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9.  
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14.  
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. # If given no args, create `configure' from template file `configure.in'.
  20. # With one arg, create a configure script on standard output from
  21. # the given template file.
  22.  
  23. usage="Usage: autoconf [-h] [--help] [-m dir] [--macrodir=dir] 
  24.                 [-v] [--version] [template-file]" 
  25.  
  26. test -z "${AC_MACRODIR}" && AC_MACRODIR=@datadir@
  27. test -z "${M4}" && M4=@M4@
  28.  
  29. print_version=
  30. while test $# -gt 0 ; do
  31.    case "z${1}" in 
  32.       z-h | z--help | z--h* )
  33.          echo "${usage}" 1>&2; exit 1 ;;
  34.       z--macrodir=* | z--m*=* )
  35.          AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
  36.          shift ;;
  37.       z-m | z--macrodir | z--m* ) 
  38.          shift
  39.          test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
  40.          AC_MACRODIR="${1}"
  41.          shift ;;
  42.       z-v | z--version | z--v* )
  43.          print_version="-DAC_PRINT_VERSION"
  44.          shift ;;
  45.       z-- )     # Stop option processing
  46.         shift; break ;;
  47.       z- )    # Use stdin as input.
  48.         break ;;
  49.       z-* )
  50.         echo "${usage}" 1>&2; exit 1 ;;
  51.       * )
  52.         break ;;
  53.    esac
  54. done
  55.  
  56. case $# in
  57.   0) infile=configure.in ;;
  58.   1) infile="$1" ;;
  59.   *) echo "$usage" >&2; exit 1 ;;
  60. esac
  61.  
  62. version_only=
  63. if test z$infile = z-; then
  64.   infile=/tmp/acin.$$
  65.   trap 'rm -f $infile' 1 3 15
  66.   cat > $infile
  67. else
  68.   if test ! -s "${infile}"; then
  69.     if test $# -eq 0 -a z"$print_version" != z; then
  70.       # No error for `autoconf --version'.
  71.       infile=/dev/null
  72.       version_only=yes
  73.     else
  74.       echo "autoconf: ${infile}: No such file or directory" >&2
  75.       exit 1
  76.     fi
  77.   fi
  78. fi
  79.  
  80. tmpout=/tmp/acout.$$
  81. trap 'rm -f $tmpout; exit 1' 1 3 15
  82.  
  83. MACROFILES="${AC_MACRODIR}/acgeneral.m4 ${AC_MACRODIR}/acspecific.m4"
  84. test -r ${AC_MACRODIR}/aclocal.m4 \
  85.    && MACROFILES="${MACROFILES} ${AC_MACRODIR}/aclocal.m4"
  86. test -r aclocal.m4 && MACROFILES="${MACROFILES} aclocal.m4"
  87. MACROFILES="${print_version} ${MACROFILES}"
  88.  
  89. $M4 $MACROFILES $infile > $tmpout
  90.  
  91. # You could add your own prefixes to pattern if you wanted to check for
  92. # them too, e.g. pattern="AC_\|ILT_", except that UNIX sed doesn't do
  93. # alternation, and GNU sed is dreadfully slow.  Sigh.
  94. pattern="AC_"
  95.  
  96. status=0
  97. if grep "${pattern}" $tmpout > /dev/null 2>&1; then
  98.   echo "autoconf: Undefined macros:" >&2
  99.   grep "${pattern}" $tmpout | sed "s/.*\(${pattern}[_A-Z0-9]*\).*/\1/" |
  100.     while read name; do
  101.       grep -n $name $infile /dev/null
  102.     done | sort -u >&2
  103.   status=1
  104. fi
  105.  
  106. test z"$version_only" = z && case $# in
  107.   0) cat $tmpout > configure; chmod +x configure ;;
  108.   1) cat $tmpout ;;
  109. esac
  110.  
  111. rm -f $tmpout
  112. exit $status
  113.